#ifndef _TABLEINFOIMPL_H_
#define _TABLEINFOIMPL_H_

#include "stdafx.h"
#include <db/idatabase.h>

class CXTableInfo : public ITableInfo, public CUnknownImp
{
public:
    CXTableInfo(LPCSTR lpszName);
    virtual ~CXTableInfo(void);

public:
    BEGIN_STDCOM_MAP
    STDCOM_INTERFACE_ENTRY(ITableInfo)
    END_STDCOM_MAP

public:
    std_method_(LPCSTR, GetName)();
    std_method(Add)(IFieldInfo* pFieldInfo);
    std_method(Remove)(unsigned int nIndex);
    std_method(Remove)(LPCSTR lpszFieldName);

public:
    std_method_(ULONG, GetFieldCount)();
    std_method(GetField)(UINT nIndex, IFieldInfo** pField);
    std_method(GetField)(LPCSTR lpszName, IFieldInfo** pField);
    std_method(CreateField)(IFieldInfo** pField);

public:
    static HRESULT CreateInstance(LPCSTR lpszName, ITableInfo** ppTableInfo);

private:
    typedef _lComPtr<IFieldInfo> IFieldInfoPtr;
    typedef std::map<std::string, IFieldInfoPtr> TableStruct;
    typedef std::map<std::string, IFieldInfoPtr>::iterator TableStructIter;
    typedef std::map<std::string, IFieldInfoPtr>::const_iterator TableStructConstIter;
    TableStruct m_lstField;
    string m_strTableName;
};

#endif
